﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection;
using Pixysoft.Weblications.Sango.Protocol.section;
using Pixysoft.Weblications.Sango.Environment;
using Pixysoft.Weblications.Sango.Dao;
using Pixysoft.Weblications.Sango.Protocol;
using Pixysoft.Weblications.Sango.Protocol.player;

namespace Pixysoft.Weblications.Sango.Command.section
{
    partial class SangoSectionHandler
    {
        public section_sectioninfo section_sectioninfo(double geox, double geoy)
        {
            string userCode = SangoManager.Authentication();

            section_sectioninfo response = ReflectionManager.CreatePojo<section_sectioninfo>();
            response.Succeed = false;

            Entities.Sys_Section sysSection = SysSectionHelper.trySearchSectionByGeolocation(geox, geoy);
            Entities.Cti_Section citySection = CitySectionHelper.searchSectionByCode(sysSection.Sectionserialcode);
            Entities.Usr_Section userSection = UsrSectionDao.GetSection(userCode);

            response.section = UsrSectionFacade.ToSection(sysSection, citySection);
            response.profiles = UsrSectionFacade.ToProfilesBySection(
                UsrSectionDao.GetSectionProfilesExclude(userCode, 0, citySection.Sectionserialcode, userSection.Scaletypecode, geox, geoy));
            response.Succeed = true;
            return response;
        }
    }

    public interface section_sectioninfo : ISangoResponse
    {
        player_section section { get;set;}

        List<section_profile> profiles { get;set;}
    }
}
